package com.pan.download5.factory.builder;

import com.pan.download5.config.entity.LineInfo;
import com.pan.download5.factory.DirectoryFactory;
import com.pan.download5.factory.PageFactory;
import com.pan.download5.factory.impl.Auto2DirectoryFactory;
import com.pan.download5.factory.impl.Auto2PageFactory;
import com.pan.download5.parse.Auto2XmlParser;
import com.pan.download5.parse.entity.auto2.Auto2InfoDirectory;
import com.pan.download5.parse.entity.auto2.Auto2InfoPage;

public class Auto2AbstractFactory extends AbstractPageDirectoryFactory{


    private String pathName = "path";


    @Override
    public FactoryEntity createFactory(LineInfo lineInfo) {
        String path = getMapValue(lineInfo.getInfoMap(), pathName);
        Auto2XmlParser auto2XmlParser = new Auto2XmlParser(path);
        Auto2InfoDirectory directoryInfo = auto2XmlParser.getDirectory();
        Auto2InfoPage pageInfo = auto2XmlParser.getPage();
        DirectoryFactory auto2DirectoryFactory = new Auto2DirectoryFactory(directoryInfo);
        PageFactory auto2PageFactory = new Auto2PageFactory(pageInfo);
        return new FactoryEntity(auto2DirectoryFactory, auto2PageFactory);
    }
}
